<template>
  <div class="transition-demo">
    <h2>基础过渡示例</h2>

    <button @click="show = !show">
      {{ show ? '隐藏' : '显示' }}
    </button>

    <Transition name="fade">
      <div v-if="show" class="box">
        <h3>Hello Vue3!</h3>
        <p>这是一个带有淡入淡出效果的元素</p>
      </div>
    </Transition>
  </div>
</template>
<script setup>
import { ref } from 'vue'

const show = ref(true)
</script>
<style scoped>
.transition-demo {
  padding: 20px;
  text-align: center;
}

.box {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 30px;
  border-radius: 10px;
  margin: 20px auto;
  max-width: 300px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

/* 淡入淡出过渡效果 */
.fade-enter-active,
.fade-leave-active {
  transition: opacity 2s ease;
}

.fade-enter-from,
.fade-leave-to {
  opacity: 0;
}

button {
  padding: 10px 20px;
  background: #3498db;
  color: white;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-size: 16px;
}

button:hover {
  background: #2980b9;
}
</style>
